// @ts-ignore
/* eslint-disable */

import { request, type RequestOptions } from '@/utils/request';

/**
 * 上传文件
 * @returns
 */
export async function fileUpload(options?: RequestOptions) {
  return request<string>(`weixin/file-upload`, {
    method: 'POST',
    ...(options || {}),
  });
}

/**
 * 获取用户头像
 * @param openId 用户openId
 * @returns
 */
export async function icon(openId: string, options?: RequestOptions) {
  return request<any>(`weixin/icon/${openId}`, {
    method: 'GET',
    ...(options || {}),
  });
}

/**
 * 获取token
 * @param input 用户微信输入
 * @returns
 */
export async function token(input: UserWeixinInut, options?: RequestOptions) {
  return request<string>(`weixin/token`, {
    method: 'POST',
    data: input,
    ...(options || {}),
  });
}

/**
 * 获取openid
 * @param code 微信code
 * @returns
 */
export async function openid(code: string, options?: RequestOptions) {
  return request<string>(`weixin/openid`, {
    method: 'GET',
    params: { 'code': code },
    ...(options || {}),
  });
}

/**
 * 获取手机号
 * @param code 微信code
 * @returns
 */
export async function phone(code: string, options?: RequestOptions) {
  return request<string>(`weixin/phone`, {
    method: 'GET',
    params: { 'code': code },
    ...(options || {}),
  });
}

/**
 * 获取微信token
 * @returns
 */
export async function wxToken(options?: RequestOptions) {
  return request<string>(`weixin/wx-token`, {
    method: 'GET',
    ...(options || {}),
  });
}
